﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BloomsburyBanHang.DAO;

namespace BloomsburyBanHang
{
    public partial class Admin_Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txt_Pass.Text = "tmdt";
                txt_Username.Text = "kinhdoanh16";
            }
        }

        protected void Btn_Login_Click(object sender, EventArgs e)
        {
            string username = txt_Username.Text;
            string pass = txt_Pass.Text;
            string ten = List_MoGioi.SelectedValue;
            NHA_MO_GIOI mogioi = NhaMoGioiDAO.layNMGtheoten(ten);
            //string SID = (string)WebserviceInvoker.WSInvoker.CallWebService(mogioi.URL, "Service1", "Login", new object[] { username, pass });
            string SID = (string)WebserviceInvoker.WSInvoker.CallWebService(mogioi.URL, mogioi.TenService, mogioi.TenHamLogin, new object[] { username, pass });
            if (SID == "LoginFail")
                this.Label1.Text = "dang nhap that bai!!";
            else
            {
                Session["username"] = username;
                Session["pass"] = pass;
                string strNhaMoiGioi = WSRequest.ObjectToXML(NhaMoiGioiDTO.Convert(mogioi));
                Session["NhaMoGioi"] = strNhaMoiGioi;
                Session["SID"] = SID;
                this.Label1.Text = "dang nhap thanh cong!!";
            }
            //this.Label1.Text = SID;
        }

       
    }
}